package com.company.pddpre09;

import java.util.Scanner;

public class Main1 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[][] res = getData(n);
        for (int i = 0; i < n; i++) {
            for(int j = 0;j < n;j++){
                System.out.print(res[i][j]);
                System.out.print(" ");
            }
            System.out.println();
        }

    }

    private static int[][] getData(int n){
        int[][] res = new int[n][n];
        boolean flag = (n & 1) == 1;
        int half = n >> 1;
        if(flag){
            // 奇数
            for(int i = 0;i < n;i++){
                for(int j = 0;j < n;j++){
                    // 对角线
                    if(i == j || i + j + 1 == n){
                        res[i][j] = 0;
                    }
                    // 一半位置
                    if(i == half || j == half){
                        res[i][j] =0;
                    }
                    // 1 和 8
                    if(i < half && j > half){
                        if(i + j + 1 < n){
                            res[i][j] = 1;
                        }
                        if(i + j + 1 > n){
                            res[i][j] = 8;
                        }
                    }
                    // 2和3
                    if(i < half && j < half){
                        if(i > j){
                            res[i][j] = 3;
                        }
                        if(i < j){
                            res[i][j] = 2;
                        }
                    }
                    // 4和5
                    if(i > half && j < half){
                        if(i + j + 1 < n){
                            res[i][j] = 4;
                        }
                        if(i + j + 1 > n){
                            res[i][j] = 5;
                        }
                    }
                    // 6和7
                    if(i > half && j > half){
                        if(i > j){
                            res[i][j] = 6;
                        }
                        if(i < j){
                            res[i][j] = 7;
                        }
                    }

                }
            }

        }else{
            // 偶数
            for(int i = 0;i < n;i++){
                for(int j = 0;j < n;j++){
                    // 对角线
                    if(i == j || i + j + 1 == n){
                        res[i][j] = 0;
                    }
                    // 1 和 8
                    if(i < half && j >= half){
                        if(i + j + 1 < n){
                            res[i][j] = 1;
                        }
                        if(i + j + 1 > n){
                            res[i][j] = 8;
                        }
                    }
                    // 2和3
                    if(i < half && j < half){
                        if(i > j){
                            res[i][j] = 3;
                        }
                        if(i < j){
                            res[i][j] = 2;
                        }
                    }
                    // 4和5
                    if(i >= half && j < half){
                        if(i + j + 1 < n){
                            res[i][j] = 4;
                        }
                        if(i + j + 1 > n){
                            res[i][j] = 5;
                        }
                    }
                    // 6和7
                    if(i >= half && j >= half){
                        if(i > j){
                            res[i][j] = 6;
                        }
                        if(i < j){
                            res[i][j] = 7;
                        }
                    }

                }
            }

        }
        return res;
    }
}
